
<!DOCTYPE html>
<html>

<head>

    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>添加检测机构信息</title>
    <link rel="shortcut icon" href="favicon.ico"> 
    <link href="${WEB_PATH}/resources/css/bootstrap.min.css?v=3.3.5" rel="stylesheet">
    <link href="${WEB_PATH}/resources/css/plugins/bootstrap-table/bootstrap-table.css" rel="stylesheet">
    <link href="${WEB_PATH}/resources/css/plugins/bootstrap-table/bootstrap-editable.css" rel="stylesheet">
    <link href="${WEB_PATH}/resources/css/font-awesome.min.css?v=4.4.0" rel="stylesheet">
    <link href="${WEB_PATH}/resources/css/plugins/chosen/chosen.css" rel="stylesheet">
    <link href="${WEB_PATH}/resources/css/style.min.css?v=5.0.0" rel="stylesheet"><base target="_blank">
	<link href="${WEB_PATH}/resources/css/plugins/sweetalert/sweetalert.css" rel="stylesheet">
	<link href="${WEB_PATH}/resources/css/plugins/datapicker/datepicker3.css" rel="stylesheet">
	<link href="${WEB_PATH}/resources/css/plugins/treeview/bootstrap-treeview.css" rel="stylesheet">
    <link href="${WEB_PATH}/resources/css/plugins/jsTree/style.min.css" rel="stylesheet">
	<link href="${WEB_PATH}/resources/css/plugins/awesome-bootstrap-checkbox/awesome-bootstrap-checkbox.css" rel="stylesheet">
	<style>
    	.demo:after {
		    background-color: #F5F5F5;
		    border: 1px solid #DDDDDD;
		    border-radius: 4px 0 4px 0;
		    color: #9DA0A4;
		    content: "所在位置：";
		    font-size: 12px;
		    font-weight: bold;
		    left: -1px;
		    padding: 3px 7px;
		    position: absolute;
		    top: -1px;
		}
		.demo {
		    margin-left: 0px;
		    padding:40px 15px 0px;
		    border: 1px solid #DDDDDD;
		    border-radius: 4px;
		    position: relative;
		    word-wrap: break-word;
		} 
		#map_coordinate {width:100%; height:370px;overflow: hidden;margin:0;}
    </style>
</head>

<body>
	<div class="col-sm-12">
		<form class="m-t" id="addTsorganizationInfo">
    		 <div class="row">
    		 	<div class="col-sm-6"> 
                    <div class="form-group">
                        <label>检测机构名称：</label>
                        <input id="text" name="JYJGMC" id="JYJGMC"   type="text"  class="form-control" placeholder="请输入检测机构名称">
                    </div>
                </div>
                <div class="col-sm-6">
                    <div class="form-group">
                        <label>组织机构代码：</label>
                        <input id="ZZJGDM" name="ZZJGDM"    type="text"  class="form-control" placeholder="请输入组织机构代码">
                    </div> 
                </div>
                 
             </div>
             <div class="row">
    		 	<div class="col-sm-6"> 
                    <div class="form-group">
                        <label>视频服务器IP：</label>
                        <input id="text" name="VIEDOIP" id="VIEDOIP"   type="text"  class="form-control" placeholder="请输入视频服务器IP">
                    </div>
                </div>
                <div class="col-sm-6">
                    <div class="form-group">
                        <label>视频服务器端口：</label>
                        <input id="VIEDOIPPORT" name="VIEDOIPPORT"    type="text"  class="form-control" placeholder="请输入视频服务器端口">
                    </div> 
                </div>
             </div>
             <div class="row">
                <div class="col-sm-4">
                    <div class="form-group">
                        <label>注册日期：</label>
                        <input type="text" class="input-sm form-control" id="KZHJRQ" name="KZHJRQ" style="background-color: #FFF;" placeholder="请选择开展环检日期" readonly />
                    </div> 
                </div>
                <div class="col-sm-4">
                    <div class="form-group">
                        <label>资质认定（计量认证）有效期：</label>
                        <input type="text" class="input-sm form-control" id="ZZRDYXQ" name="ZZRDYXQ" style="background-color: #FFF;" placeholder="请选择开展环检日期" readonly />
                    </div> 
                </div>
                <div class="col-sm-4">
                    <div class="form-group">
                        <label>联网日期：</label>
                        <input type="text" class="input-sm form-control" id="LWRQ" name="LWRQ" style="background-color: #FFF;" placeholder="请选择开展环检日期" readonly />
                    </div> 
                </div>
             </div>
             <div class="row">
    		 	<div class="col-sm-4"> 
                    <div class="form-group">
                        <label>法人代表：</label>
                        <input id="text" name="FRDB" id="FRDB"   type="text"  class="form-control" placeholder="请输入法人代表">
                    </div>
                </div>
                <div class="col-sm-4">
                    <div class="form-group">
                        <label>联系人：</label>
                        <input id="text" name="LXR" id="LXR"   type="text"  class="form-control" placeholder="请输入联系人">
                    </div> 
                </div>
                <div class="col-sm-4">
                    <div class="form-group">
                        <label>联系电话：</label>
                        <input type="text" class="form-control" id="LXDH" name="LXDH" maxlength="11" placeholder="请输入联系电话" />
                    </div> 
                </div>
             </div>
             <div class="row">
                <div class="col-sm-4">
                    <div class="form-group">
                        <label>所在地区：</label>
                        <input id="XZQHMC" name="XZQHMC" class="form-control" readonly type="text" value="" >
						<input id="XZQHDM" name="XZQHDM" type="hidden" >
                    </div>
                </div> 
               <div class="col-sm-4" id="organization_id" >
	                <div class="form-group">
	                    <label>所属组织部门：</label>
	                     <div class="input-group colorpicker-demo2 colorpicker-element">
		                    <input id="SSBMNAME" name="SSBMNAME" class="form-control dropdown-toggle" readonly type="text" placeholder="请选择组织部门"  value="${user.organization.name}" style="background-color: #fff;" >
		            		<input id="SSBMID" name="SSBMID"  type="hidden" >
		            		<input id="SSBMCODE" name="SSBMCODE"  type="hidden" >
		                	<span class="dropdown-toggle input-group-addon  btn btn-white btn-bitbucket" data-toggle="dropdown" id="organization"><i class="fa fa-user-md"></i></span>
		                	<div class="dropdown-menu m-t-xs pull-right" id="organization_tree" style="width: 100%;">
		                        <div id="organizationTree" style="padding: 10px;height:300px;overflow-y:scroll;"></div>
		                    </div>
		                </div>
					</div>
	            </div>   
                <div class="col-sm-4">
	                <div class="form-group">
	                    <label >状态：</label>
	                    <div class="col-sm-4 form-control">
	                        <div class="radio radio-success radio-inline "  >
	                           <input type="radio"  value="zc" name="JYJGZD" id="status1">
	                           <label for="status1">正常</label>
	                        </div>
	                        <div class="radio radio-warning radio-inline" data-toggle="tooltip" data-trigger="hover" data-class="radio-success" title="停业：检测机构将无法进行检测数据的上传和报告的打印！">
	                            <input type="radio"  id="status2" value="ty" name="JYJGZD">
	                            <label for="status2">停业</label>
	                        </div>
	                        <div class="radio radio-warning radio-inline" data-toggle="tooltip" data-trigger="hover" data-class="radio-success" title="断网：检测机构将无法进行检测数据的上传！">
	                            <input type="radio"  id="status3" value="dw" name="JYJGZD">
	                            <label for="status3">断网</label>
	                        </div>
	                        <div class="radio radio-danger radio-inline" data-toggle="tooltip" data-trigger="hover" data-class="radio-success" title="注销：将会使检该测机构下的用户，无法进行登陆使用！">
	                            <input type="radio"  id="status4" value="zx" name="JYJGZD">
	                            <label for="status4">注销</label>
	                        </div>
	                        <div class="radio radio-success radio-inline "  >
	                           <input type="radio"  value="wy" name="JYJGZD" id="status1" checked="">
	                           <label for="status1">未接入</label>
	                        </div>
	                    </div>
	                </div> 
	             </div>  
	             
	             <div class="col-sm-8">
                    <div class="form-group">
                        <label>所在地址：</label>
                        <input name="JYJGDZ" id="JYJGDZ" minlength="2" type="text"  class="form-control" placeholder="请输入所在地址">
                    </div>
                </div>
                
	             <div class="col-sm-12" style="padding-top: 10px;display: none;" id="map_div" >
	            	 <div style="" class="demo ui-sortable">
	            	     <div id="map_coordinate"></div>
	            	     <input  name="ZBDZ" id="ZBDZ" type="hidden">
                    </div>
	            </div>
            </div>  
        </form> 
		</div>
	</div>
    <script src="${WEB_PATH}/resources/js/jquery.min.js?v=2.1.4"></script>
    <script src="${WEB_PATH}/resources/js/ajax.extend.js"></script>
    <script src="${WEB_PATH}/resources/js/bootstrap.min.js?v=3.3.5"></script>
	<script src="${WEB_PATH}/resources/js/plugins/datapicker/bootstrap-datepicker.js"></script>
    <script src="${WEB_PATH}/resources/js/plugins/wizard/jquery.bootstrap.wizard.js"></script>
    <script src="${WEB_PATH}/resources/js/plugins/validate/jquery.validate.min.js"></script>
    <script src="${WEB_PATH}/resources/js/plugins/validate/messages_zh.min.js"></script>
    <script src="${WEB_PATH}/resources/js/plugins/validate/jquery.validate.method.js"></script>
	<script src="${WEB_PATH}/resources/js/plugins/layer/layer.js"></script> 
	<script src="${WEB_PATH}/resources/js/city-picker.data.js"></script>
	<script src="${WEB_PATH}/resources/js/city-picker.js"></script>
	<script src="${WEB_PATH}/resources/js/plugins/jsTree/jstree.min.js"></script>
	<script src="${WEB_PATH}/resources/js/plugins/sweetalert/sweetalert.min.js"></script>
	<script src="${WEB_PATH}/resources/js/plugins/chosen/chosen.jquery.js"></script>
	<script type="text/javascript" src="http://api.map.baidu.com/api?v=1.5&ak=B3f7707c25da5b29a6ff69618788a296"></script>
	 <script>
	$(function(){
		$("[data-toggle='tooltip']").tooltip();
    	$("#KZHJRQ").datepicker({
	        keyboardNavigation: !1,
	        forceParse: !1,
	        autoclose: !1,
	        todayBtn:'linked'
	    });
	    $("#ZZRDYXQ").datepicker({
	        keyboardNavigation: !1,
	        forceParse: !1,
	        autoclose: !1,
	        todayBtn:'linked'
	    });
	    $("#LWRQ").datepicker({
	        keyboardNavigation: !1,
	        forceParse: !1,
	        autoclose: !1,
	        todayBtn:'linked'
	    });
	    $('#XZQHMC').citypicker({areaId:'XZQHDM'}); 
	    $('#JYJGDZ').blur(function(){
		     TaggingMap();
		});
		$("#organization").on("click",function(){
			var display =$('#organization_tree').css('display');
			if(display == 'none'){
			  $("#organization_tree").show();
			}else{
			  $("#organization_tree").hide();
			}
		});
		$('#organizationTree').jstree({'core' : {
			 'data': ${json}
		}}).bind("loaded.jstree", function () { 
        }).bind('changed.jstree', function(event,data) {
           $("#SSBMNAME").val(data.node.text);
	       $("#SSBMID").val(data.node.original.id);
	       $("#organization_tree").hide();
	    });
    });
	var e = "<i class='fa fa-times-circle'></i> ";
	var $addTsorganizationInfo =  $('#addTsorganizationInfo').validate({
		  rules: {
		    JYJGMC: {
		      required: true
		    },
		    ZZJGDM: {
		      required: true
		    },
		    JYJGDZ: {
		      required: true
		    }, 
		    XZQHMC:{
		      required: true
		    }  
		  },
		  messages: {
            name: {
                remote:e+"商户名已存在，请重新输入！"
            }
          },
		  errorPlacement: function(error, element) {
		  		if(element.get(0).id == "XZQHMC"){
            		$('#XZQHMC').citypicker("setError");
            	}
            	element.before(error);
            	if(element.get(0).id == "SSBMNAME"){
            		element.context.parentNode.addClass('error');
            	}
          }
	});
     //添加用户信息#commentForm
 	function saveTsorganizationInfo(){
 		if($('#addTsorganizationInfo').valid()){
 			 if($('#SSBMNAME').val() == ""){
 			 	layer.msg('请选择所属组织部门！', {icon: 5}); 
		   		return false;
 			 }
 			 var tsorganizationInfo = $('#addTsorganizationInfo').serializeJson(); 
			 $.yilinAjax({
		   	  	type:'POST',
		   	  	loadmsg:'努力提交中......',
		   	  	url:'${WEB_PATH}/reg/tsorganization/save.do',
		   	  	data:tsorganizationInfo,
		   	  	btn:null,
        		errorcallback:null,
        		successcallback:success
		   	 });
    	}
 	}
 	
 	function success(result){
 		if(result.success == true){
	    	layer.alert('<font color="#1ab394">'+result.msg+'</font>', {
			  	skin: 'layui-layer-molv',
			  	icon: 1,
			  	closeBtn: 0
			},function(){
				parent.$("#exampleTableEvents").bootstrapTable('refresh');
				var index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
				parent.layer.close(index); 
			});
		}else{
			$('#saveBut').attr("disabled",false); 
		 	$('#subBut').attr("disabled",false);       
	    	layer.alert('<font color="red">'+result.msg+'</font>', {
			  skin: 'layui-layer-molv' ,
			  closeBtn: 0,
			  icon: 5,
			});
		}
 	}
 	
 	function TaggingMap(){
 	    $("#map_div").show();
		var map = new BMap.Map("map_coordinate"); 
		map.centerAndZoom(new BMap.Point(85.021158,41.283069, 5));
		map.enableScrollWheelZoom();//启动鼠标滚轮缩放地图
		map.enableKeyboard();//启动键盘操作地图
		// 创建地址解析器实例
		var myGeo = new BMap.Geocoder();
		var text = $("#XZQHMC").val().replace("-","") + $("#JYJGDZ").val();
		// 将地址解析结果显示在地图上,并调整地图视野
		myGeo.getPoint(text, function(point){
			if (point) {
				map.centerAndZoom(point, 16);
				map.addOverlay(new BMap.Marker(point));
				$("#ZBDZ").val(point.lng+","+point.lat);
			}else{
				layer.msg('<font color="red">您输入地址没有解析到所在位置,请手动选择！。</font>', {icon: 5,time: 2000});
			}
		}, "新疆维吾尔自治区");
		
		map.addEventListener("click", function(e){
			map.clearOverlays();
			var point = e.point;
			map.enableScrollWheelZoom();//启动鼠标滚轮缩放地图
			map.enableKeyboard();//启动键盘操作地图
			map.addOverlay(new BMap.Marker(point));
			$("#ZBDZ").val(point.lng+","+point.lat);
		});
 	}
  </script>
</body>
</html>